'use strict';

angular.module('fbdApp.auxModule')

.factory('fbdService', function($http, $q) {
  return {
    test: function(url, postData) {

      var req = {
        method: 'POST',
        url: url,
        data: postData

      };

      var deferred = $q.defer();

      $http(req).success(function(res) {
        deferred.resolve(res);
        // console.log(res);
      }).error(function(err) {
        deferred.reject(err);
      });
      return deferred.promise;
    },

    save: function(url, addData) {

      var req = {
        method: 'POST',
        url: url,
        data: addData
      };
      var deferred = $q.defer();

      $http(req).success(function(res) {
        deferred.resolve(res);
        // console.log(res);
      }).error(function(err) {
        deferred.reject(err);
      });
      return deferred.promise;
    }
  };
});
